package cn.edu.nuaa.computer.utils;

import java.util.Objects;

public class MyData {
    private Double num;
    /**
     * 符号
     */
    private Character symbol;

    public MyData() {
    }

    public MyData(Double num, Character symbol) {
        this.num = num;
        this.symbol = symbol;
    }

    public MyData(Double num) {
        this.num = num;
    }

    public MyData(Character symbol) {
        this.symbol = symbol;
    }

    public Double getNum() {
        return num;
    }

    public void setNum(Double num) {
        this.num = num;
    }

    public Character getSymbol() {
        return symbol;
    }

    public void setSymbol(Character symbol) {
        this.symbol = symbol;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MyData myData = (MyData) o;
        return Objects.equals(num, myData.num) && Objects.equals(symbol, myData.symbol);
    }

    @Override
    public int hashCode() {
        return Objects.hash(num, symbol);
    }

    @Override
    public String toString() {
        if (num != null) {
            return "{" + num + "}";
        } else {
            return "{" + symbol + "}";
        }
    }
}
